﻿
@{
    ViewBag.Title = "AddUnitInfo";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>

    <link href="//unpkg.com/layui@2.9.17/dist/css/layui.css" rel="stylesheet">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">单位编码</label>
            <div class="layui-input-block">
                <input type="text" name="unitCode" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单位名称</label>
            <div class="layui-input-block">
                <input type="text" name="unitName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否主单位</label>
            <div class="layui-input-block">
                <input type="radio" name="unitFlag" value="1" title="是" checked>
                <input type="radio" name="unitFlag" value="0" title="否">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="isEnable" value="1" title="是" checked>
                <input type="radio" name="isEnable" value="0" title="否">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="remark"></textarea>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        layui.use('form', function () {
            var form = layui.form;
            form.render();
            
            // 自定义验证规则
            form.verify({
                unitCode: function (value) {
                    if (!value) { layer.msg("单位编码不能为空"); return true; };
                },
                unitName: function (value) {
                    if (!value) { layer.msg("单位名称不能为空"); return true; };
                },
                remark: function (value) {
                    if (!value) { layer.msg("备注不能为空"); return true; };
                },
            })
        })
    </script>
</body>
</html>